import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:klfz_flutter/book/book_detail/view.dart';
import 'package:klfz_flutter/config/RouteConfig.dart';

import 'logic.dart';

class BookPage extends StatelessWidget {
  final BookLogic logic = Get.put(BookLogic());
  @override
  Widget build(BuildContext context) {
    logic.loadData();
    return Scaffold(
        floatingActionButton: FloatingActionButton(
          onPressed: () => logic.loadData(),
          child: Icon(Icons.add),
        ),
      appBar: AppBar(title: Text("书籍"),),
      body: Container(
       child: GetBuilder<BookLogic>(
         builder: (logic) {
           return ListView.builder(
             itemBuilder: (context, index) {
               return ListTile(
                 onTap: () {
                   Get.toNamed(RouteConfig.getBookDetail, arguments: logic.data[index]);
                 },
                 title: Text(logic.data[index].bookname ?? "", style: TextStyle(color: Colors.red),),
               );
             },
             itemCount: logic.data.length,
           );
         },
       )
      )
    );
  }
}

